﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: OrderByExpression.cs
//
//  Description: Class that holds one order by expression.
// 
//--------------------------------------------------------------------------


using System;
using System.Linq.Expressions;
using OrderDirection = Chili.Opf3.Query.SortDirections;

namespace Chili.Opf3.Linq
{
	/// <summary>
	/// This class holds one order by expression. It holds additional information,
	/// such as the direction of the order.
	/// </summary>
	internal sealed class OrderByExpression
	{
		private Expression _expression;
		private OrderDirection _direction;

		/// <summary>
		/// Creates a new instance of the <see cref="OrderByExpression">OrderByExpression Class</see>.
		/// </summary>
		/// <param name="expression">The order by expression.</param>
		/// <param name="direction">The direction of the order.</param>
		public OrderByExpression(Expression expression, OrderDirection direction)
		{
			if (expression == null)
				throw new ArgumentNullException("expression");
			_expression = expression;
			_direction = direction;
		}

		/// <summary>
		/// Gets the order by expression.
		/// </summary>
		public Expression Expression
		{
			get { return _expression; }
		}

		/// <summary>
		/// Gets the direction of the order.
		/// </summary>
		public OrderDirection Direction
		{
			get { return _direction; }
		}
	}
}
